<?php
class jphpdom extends DOMDocument {

static $_start=0;
static $_instance=””;

function  __construct($value=null){
//Initialize the document with DOMDocument
if($value!=null){
    if((strlen($value)==strlen(strip_tags($value)))&&(file_exists($value))){
    if($this->loadHTMLFile($value)){
       self::$_start=1;
   self::$_instance=$this;
    }
    }
    else
    if($this->loadHTML($value)){
       self::$_start=1;
       self::$_instance=$this;
    }
}

//Select the elements with a specific sintax

}

public function attr(){} //Managing attributes (name, href) and for setting and for getting.
public function val(){} //Managing the attribute “value”.
public function html(){} //Managing the content of the html elements and tags (div, td, li)

public function loadHTML($value){
  if(parent::loadHTML($value)){
       self::$_start=1;
   self::$_instance=$this;
    }
}

public function loadHTMLFile($value){
  if(parent::loadHTMLFile($value)){
       self::$_start=1;
   self::$_instance=$this;
    }
}

}

function j(){
    if(!jphpdom::$_start)
      throw new Exception('There isn\’t a valid istance.');

       return jphpdom::$_instance->saveHTML();
}

$jphpdom = new jphpdom;
$jphpdom->loadHTMLFile("file.html");
echo j();

?>